package com.android.kotlincoroutinemvvmdemo.common_singleton

/*
* 通用创建公共单例类模版
* */
abstract class Singleton<T> {

    private var mInstance: T? = null

    protected abstract fun create(): T

    fun get(): T? {
        synchronized(this) {
            if (mInstance == null) {
                mInstance = create()
            }
        }
        return mInstance
    }
}